<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, maximum-scale=1, initial-scale=1, user-scalable=yes">
    {php}echo app('seo')->buildHtml($vars);{/php}
    <link rel="shortcut icon" href=""/>
    <link rel="stylesheet" href="__UCENTER__/green/css/qietu.css">
    <link rel="stylesheet" href="__UCENTER__/green/font/iconfont.css">
    <link rel="stylesheet" href="__UCENTER__/green/css/header.css">
    <link rel="stylesheet" href="__UCENTER__/green/css/style.css">
    <link rel="stylesheet" href="__UCENTER__/green/css/responsive.css">
</head>

<body class="loginpage-bg">

<div class="loginpage">

    <div class="login-wrap">
        <div class="login-left">
            <img src="__UCENTER__/green/imgs/img_32.jpg"/>
        </div>
        <div class="login-right ">
            <form method="post" action="">
                <div class="head">
                    {eq name='module' value='admin'}
                    <h3>管理员登录</h3>
                    <p>登录您的管理后台</p>
                    {else/}
                    <h3>商户登录</h3>
                    <p>登录您的商户后台</p>
                    {/eq}
                </div>
                <div class="body" style="margin-top: 35px;">
                    <ul>
                        <li>
                            <i class="iconfont icon-yonghu"></i>
                            <input type="text" class="txt" name="username" id="username" value="" placeholder="输入用户名"/>
                        </li>
                        <li>
                            <i class="iconfont icon-mima"></i>
                            <input type="password" class="txt" name="password" id="password" value=""
                                   placeholder="输入密码"/>
                        </li>

                        <li id="captcha_div">
                            <i class="iconfont icon-protocol-audit"></i>
                            <input type="text" class="txt" name="captcha" id="captcha" value="" style="width: 130px" placeholder="输入验证码"/>
                            <img src="{:captcha_src()}" class="captcha_img" title="点击更换验证码" style="width: 130px;cursor:pointer "/>
                        </li>
                    </ul>


                </div>
                <div class="foot">
                    <input type="hidden" name="module" value="{$module}"/>
                    <input type="hidden" name="__token__" value="{:token()}"/>
                    <input type="button" class="btn" id="login_btn" value="登 录"/>
                    <p></p>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript" src="__UCENTER__/green/js/jquery.js"></script>
<script type="text/javascript" src="__UCENTER__/green/js/script.js"></script>
<script src="__STATIC__/common/layer/layer.js"></script>
<script>
    $('#login_btn').click(function () {
        if ($('#username').val() == '') {
            layer.msg('请输入用户名');
            return false;
        }
        if ($('#password').val() == '') {
            layer.msg('请输入密码');
            return false;
        }
        login();
    })
    var verifyimg = $(".captcha_img").attr("src");
    $(".captcha_img").click(function(){
        if( verifyimg.indexOf('?')>0){
            $(".captcha_img").attr("src", verifyimg+'&random='+Math.random());
        }else{
            $(".captcha_img").attr("src", verifyimg.replace(/\?.*$/,'')+'?'+Math.random());
        }
    });
    function login() {
        var loading = '';//11111
        $.ajax({
            type: 'post',
            url: "",
            dataType: "json",
            data: $("form").serialize(),
            beforeSend: function (xhr) {
                loading = layer.load()
            },
            success: function (res) {
                layer.close(loading);
                if (res.code == 0) {
                    window.location.href = res.url;
                } else {
                    $(".captcha_img").click();
                    layer.msg(res.message);
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                var re = JSON.parse(XMLHttpRequest.responseText);
                layer.close(loading);
                layer.msg(re.message);
            }
        });
    }

    $(document).keyup(function (event) {
        if (event.keyCode == 13) {
            $("#login_btn").trigger("click");
        }
    })
</script>


</body>
</html>

